package com.depository.oss;

import com.aliyun.oss.OSSClient;
import com.depository.oss.config.OSSParameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class DefaultOSSClient {
	
	@Autowired
	private static OSSParameter parameter;

    private static OSSClient client;

    private DefaultOSSClient() {
    	
    }
    public static OSSClient getDefaultOSSClient(){      
        if(client == null){
            client = new OSSClient(parameter.ENDPOINT, parameter.ACCESSKEYID, parameter.ACCESSKEYSECRET);      
        }
        System.out.println("*******************************************************"+parameter.ENDPOINT);
        return client;
    }

    public static void shutdownOSSClient(){     
        client.shutdown();
        client = null;      
    }    
}
